package com.owen.spark.test

import org.apache.spark.{SparkConf, SparkContext}

/**
 * 累加器示例
 */
object Accumulator {
  def main(args: Array[String]): Unit = {
    var conf = new SparkConf()
    conf.setAppName("join").setMaster("local[*]")

    var sc = new SparkContext(conf)
    var counter = 0
    val data = Array(1, 2, 3, 4, 5)
    sc.parallelize(data).foreach(x => counter += x)
    println(counter)
  }
}
